//
//  MBGoodsTableViewCellModel.m
//  MemberBusiness-ios
//
//  Created by cherry pu on 2018/4/23.
//  Copyright © 2018年 zhangXin. All rights reserved.
//

#import "MBGoodsTableViewCellModel.h"
#import "MBGoodsNetTool.h"

@interface MBGoodsTableViewCellModel ()
@property (nonatomic,strong) MBGoodsModel *dataModel;
@end

@implementation MBGoodsTableViewCellModel
@dynamic dataModel;

- (NSNumber*)totalHeight
{
    return @([UIView lf_sizeFromIphone6:110]);
}

-(void)goodsLower
{
    MBLoginUserModel* userModel = [MBLoginUserModelArchieveTool userInfoUnAchieveFromFile];
    MBSellerGoodsParam* param = [[MBSellerGoodsParam alloc]init];
    param.goods_id = self.dataModel.goods_id;
    param.is_on_sale = !self.dataModel.is_on_sale;
    param.token = userModel.token;
    [MBGoodsNetTool netToolPostGoodsLowerParam:param success:^(MBHTTPResponse *response) {
        if (response.status == 1) {
            [self.cellSelectedSignal sendNext:self.dataModel];
            [InterfaceHUD showSuccessHUDWithString:response.msg];
        }else {
            [InterfaceHUD showErrorHUDWithString:response.msg];
        }
    } failure:^(NSError *error) {
        [InterfaceHUD showErrorHUDWithString:@"操作失败，请稍后重试！"];
    }];
}

@end
